package com.office.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.office.common.annotation.Log;
import com.office.common.core.controller.BaseController;
import com.office.common.core.domain.AjaxResult;
import com.office.common.enums.BusinessType;
import com.office.system.domain.SysReturn;
import com.office.system.service.ISysReturnService;
import com.office.common.utils.poi.ExcelUtil;
import com.office.common.core.page.TableDataInfo;

/**
 * 归还管理Controller
 * 
 * @author ruoyi
 * @date 2024-07-23
 */
@RestController
@RequestMapping("/system/return")
public class SysReturnController extends BaseController
{
    @Autowired
    private ISysReturnService sysReturnService;

    /**
     * 查询归还管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:return:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysReturn sysReturn)
    {
        startPage();
        List<SysReturn> list = sysReturnService.selectSysReturnList(sysReturn);
        return getDataTable(list);
    }

    /**
     * 导出归还管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:return:export')")
    @Log(title = "归还管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysReturn sysReturn)
    {
        List<SysReturn> list = sysReturnService.selectSysReturnList(sysReturn);
        ExcelUtil<SysReturn> util = new ExcelUtil<SysReturn>(SysReturn.class);
        util.exportExcel(response, list, "归还管理数据");
    }

    /**
     * 获取归还管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:return:query')")
    @GetMapping(value = "/{returnId}")
    public AjaxResult getInfo(@PathVariable("returnId") Long returnId)
    {
        return success(sysReturnService.selectSysReturnByReturnId(returnId));
    }

    /**
     * 新增归还管理
     */
    @PreAuthorize("@ss.hasPermi('system:return:add')")
    @Log(title = "归还管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysReturn sysReturn)
    {
        return toAjax(sysReturnService.insertSysReturn(sysReturn));
    }

    /**
     * 修改归还管理
     */
    @PreAuthorize("@ss.hasPermi('system:return:edit')")
    @Log(title = "归还管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysReturn sysReturn)
    {
        return toAjax(sysReturnService.updateSysReturn(sysReturn));
    }

    /**
     * 删除归还管理
     */
    @PreAuthorize("@ss.hasPermi('system:return:remove')")
    @Log(title = "归还管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{returnIds}")
    public AjaxResult remove(@PathVariable Long[] returnIds)
    {
        return toAjax(sysReturnService.deleteSysReturnByReturnIds(returnIds));
    }
}
